<template>
    <div class="login">
        <div class="container">
            <!-- 12列 - Bootstrap4 -->
            <div class="row">
                <div class="col-xs-12 col-sm-9 col-md-7 col-lg-5 pt-5 m-auto">
                    <div class="card mt-5">
                        <div class="card-header">
                            <h3 class="text-center mb-0 text-secondary">{{ $conf.logo }}</h3>
                        </div>
                        <div class="card-body">
                            <el-form ref="rulesForm" :model="form" :rules="rules">
                                <el-form-item prop="username">
                                    <el-input v-model="form.username" size="medium" placeholder="请输入用户名"></el-input>
                                </el-form-item>
                                <el-form-item prop="password">
                                    <el-input v-model="form.password" size="medium" placeholder="请输入密码" type="password">
                                    </el-input>
                                </el-form-item>
                                <el-form-item>
                                    <el-button class="w-100" type="primary" size="medium" @click="submitForm()">
                                        立即登录
                                    </el-button>
                                </el-form-item>
                            </el-form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        watch: {

        },
        created() {

        },
        mounted() {

        },
        data() {
            return {
                // 表单数据
                form: {
                    username: '',
                    password: ''
                },
                // 验证规则
                rules: {
                    username: [{
                        required: true,
                        message: '请输入用户名',
                        trigger: 'blur'
                    }],
                    password: [{
                        required: true,
                        message: '请输入密码',
                        trigger: 'blur'
                    }]
                }
            };
        },
        methods: {
            // 校验表单，没问题提交
            submitForm() {
                this.$refs['rulesForm'].validate((valid) => {
                    // 校验不通过直接返回，不再往下
                    if (!valid) return;
                    
                    // 跳转后台首页
                    this.$router.push ({
                        name: 'index'
                    });
                });
            }
        },
        computed: {

        },
        components: {

        }
    };
</script>

<style scoped>

</style>